#include <stdio.h>
#include <execinfo.h>
#include "libutils/dump_hex.c"
#define ARRAY_COUNT 30
#define SHOW_FUNC_ADDR( FUNC_NAME )	\
	printf("---- %s \t: 0x%08x ----\n" , #FUNC_NAME , FUNC_NAME );
int main();

void f(int k){
	SHOW_FUNC_ADDR( f );

	int i;
	void * bt_buf[ ARRAY_COUNT ];

	int bt_num = backtrace( bt_buf  , ARRAY_COUNT );
	for(i=0;i<bt_num;i++){
		printf("stack:0x%08x value:0x%08x\n" , bt_buf[i] , *(unsigned int *)bt_buf[i]);
	}

//	char ** str_array = backtrace_symbols( bt_buf , bt_num );
	backtrace_symbols_fd( bt_buf , bt_num , fileno(stdout));
//	for( i=0 ; i<bt_num ; i++ ){
		
//		print_hex_dump( (unsigned char * )bt_buf[i] , 100 );
	
			
		
//		printf( "bt:%s\n" , str_array[i] );
//	}
	return;
}
void h(){
	SHOW_FUNC_ADDR(h);
	f(8);
	return;
}
void g(){
	SHOW_FUNC_ADDR(g);
	h();
	return;
}
int main(){
	SHOW_FUNC_ADDR(main);
	g();
	return 0;
}
